package gui;
import java.util.Comparator;
import org.eclipse.swt.graphics.Point;

/**
 * Cell class
 * contains Point object & String object.
 * the point object represents the location of the cell in the gui's table
 * the String object represents the cell's content.
 * also implemets Comparator in order to sort from high to low.
 * @author michal
 *
 */
public class Cell implements Comparator<Cell>{
	private Point cellPosition; //cell position in gui's table
	private String cellContent; //cell's content
		
	/**
	 * c-tor
	 * @param cellPosition
	 * @param cellContent
	 */
	public Cell(Point cellPosition, String cellContent) {
		super();
		this.cellPosition = cellPosition;
		this.cellContent = cellContent;
	}

	/**
	 * default c-tor
	 */
	public Cell() {
		// TODO Auto-generated constructor stub
	}

	/*********************************** 
	 * setters & getters 
	 ***********************************/

	public Point getCellPosition() {
		return cellPosition;
	}


	public void setCellPosition(Point cellPosition) {
		this.cellPosition = cellPosition;
	}


	public String getCellContent() {
		return cellContent;
	}

	public void setCellContent(String cellContent) {
		this.cellContent = cellContent;
	}

	/**
	 * compare method implementation
	 */
	@Override
	public int compare(Cell a, Cell b) {		
		if (a.getCellPosition().x < b.getCellPosition().x)
			return -1;
		else if (a.getCellPosition().x > b.getCellPosition().x)
			return 1;
		else //equal - return by lowest Y
			if (a.getCellPosition().y > b.getCellPosition().y)
				return -1;
			else return 1;
    }
	
	/**
	 * print the object
	 */
	public String toString(){
		return "("+cellPosition.x+","+cellPosition.y+")"+": "+cellContent;
	}

}
